package book_management;

import book_management.book.BookList;
import book_management.user.Admin;
import book_management.user.Normal;
import book_management.user.User;

import java.util.Scanner;

/**
 * 整个程序的入口
 *
 * @author 胡伟龙
 * @date 2022-1-13 16:54:17
 **/
public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        User user = login();
        BookList bookList = new BookList();
        while (true){
            int choice = user.menu();
            if (choice==-1){
                System.out.println("Bye~");
                break;
            }
            user.doOperation(choice,bookList);
        }
    }

    private static User login() {
        System.out.print("请输入用户名：");
        String name = scanner.next();
        System.out.println("请输入您的角色,1表示普通用户，0表示管理员");
        int choice = scanner.nextInt();
        if (choice == 1) {
            return new Normal(name);
        }
        return new Admin(name);
    }
}
